package com.xtinno.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xtinno.mapper.RuleContentMapper;
import com.xtinno.pojo.po.RuleContentPO;
import com.xtinno.service.RuleContentService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 规则内容
 *
 * @author GuanLei
 * @time 2025/5/6 17:16
 */
@Service
public class RuleContentServiceImpl extends ServiceImpl<RuleContentMapper, RuleContentPO> implements RuleContentService {


    @Override
    public List<RuleContentPO> getRuleContentPOsByRuleId(String ruleId) {
        if (StringUtils.isEmpty(ruleId)){
            return List.of();
        }
        LambdaQueryWrapper<RuleContentPO> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(RuleContentPO::getRuleId, ruleId);
        return this.list(queryWrapper);
    }

    @Override
    public Boolean saveRuleContents(List<RuleContentPO> ruleContentPOS) {
        return this.saveBatch(ruleContentPOS);
    }
}
